/*
 *  Copyright 2008 Mark Ashworth <javameme@gmail.com>.
 * 
 *  Licensed under the GNU General Public License v3 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.gnu.org/licenses/gpl-3.0.html
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package xperiment.metaphor.model.event;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import xperiment.metaphor.model.AbstractBean;
import xperiment.metaphor.model.Event;
import xperiment.metaphor.model.Persistent;

/**
 * A domain event
 * @author Mark Ashworth <javameme@gmail.com>
 * @version 1.0.0
 */
public class DomainEvent extends AbstractBean implements Persistent, Event {

    @Id @GeneratedValue(strategy=GenerationType.AUTO) 
    @Column(name = "event_id", unique = true, nullable = false)
    private Long id = null;
    
    /** The type of event */
    @Column(name = "event_type", length=125, unique=false, nullable=false)
    private String type;
    
    /* The date and time the event occurred */
    @Column(name="event_time_occurred", nullable=true)
    private Date timeOccurred;
    
    /* The date and time the event was noticed */
    @Column(name="event_time_noticed", nullable=true)
    private Date timeNoticed;
    
    /* Whether the event is enabled */
    @Column(name = "enabled", nullable = false)
    private boolean enabled = true;
    
    /**
     * Constructs a domain event
     * @param type The type of event
     * @param message The string representation of the message
     * @param timeOccurred The date and time the event occurred
     * @param timeNoticed The date and time the event was noticed
     */
    public DomainEvent(String type, Date timeOccurred, Date timeNoticed) {
        this.type = type;
        this.timeOccurred = timeOccurred;
        this.timeNoticed = timeNoticed;
    }
    
    /**
     * The unique id of the event
     * @return Long
     */
    public Long getId() {
       return this.id;
    }

    /**
     * The type of event
     * @return String
     */
    public String getType() {
        return type;
    }

    /**
     * The date and time the event occurred
     * @return Date
     */
    public Date getTimeNoticed() {
        return timeNoticed;
    }

    /**
     * The date and time the event was noticed
     * @return Date
     */
    public Date getTimeOccurred() {
        return timeOccurred;
    }
    
    /**
     * Whether the event is enabled
     * @return boolean
     */
    public boolean isEnabled() {
        return this.enabled;
    }
}
